import 'package:flutter/material.dart';
import 'package:videotop/base_view.dart';
import 'package:videotop/model/regmail_model.dart';
import 'package:videotop/mycolor.dart';
import 'package:videotop/util.dart';
import 'package:provider/provider.dart';

/// created by hx
///    2020/11/7:13:16

class RegEmail extends StatefulWidget{

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _RegUser1();
  }
}

class _RegUser1 extends State<RegEmail>{


  @override
  Widget build(BuildContext context) {
    return BaseView<RegEmailModel>(
      model: RegEmailModel(context,Provider.of<Util>(context)),
      builder: (context,model,child){
        return Scaffold(
          backgroundColor: MyColor.theme,
          resizeToAvoidBottomPadding: false,
          appBar: AppBar(
            backgroundColor: MyColor.theme,
            brightness: Brightness.dark,
            elevation: 0,
            leading: IconButton(
              icon: Image.asset(
                'assets/image/back_y.png',
                width: 25,
                height: 25,
                fit: BoxFit.fill,
              ),
              onPressed: () {
                Navigator.pop(context);
              },
            ),
            centerTitle: true,
            title: Text(
              'SETUP ACCOUNT',
              style: TextStyle(fontSize: 18, color: MyColor.yellow),
            ),
          ),
          body: Container(
            margin: EdgeInsets.only(left: 20,right: 20,top: 20),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Container(
                  decoration: BoxDecoration(
                      color: MyColor.theme2,
                      borderRadius: BorderRadius.circular((30))
                  ),
                  margin: EdgeInsets.only(top: 50),
                  padding: EdgeInsets.only(left: 20),
                  child: Row(
                    children: [
                      Image.asset(
                        'assets/image/emai_y.png',
                        width: 20,
                        height: 20,
                      ),
                      SizedBox(
                        width: 20,
                      ),
                      Expanded(
                        child: TextField(
                          maxLines: 1,
                          cursorColor: Colors.white,
                          style: TextStyle(fontSize: 15, color: Colors.white),
                          onChanged: (value) {
                            model.setEmail(value);
                          },
                          keyboardType: TextInputType.emailAddress,
                          decoration: InputDecoration(
                            border: InputBorder.none,
                            hintText: 'Email',
                            hintStyle: TextStyle(
                                fontSize: 15,
                                fontWeight: FontWeight.bold,
                                fontFamily: 'my_medium',
                                color: Colors.grey),
                          ),
                        ),
                      )
                    ],
                  ),
                ),
                Container(
                  decoration: BoxDecoration(
                      color: MyColor.theme2,
                      borderRadius: BorderRadius.circular((30))
                  ),
                  margin: EdgeInsets.only(top: 40),
                  padding: EdgeInsets.only(left: 20),
                  child: Row(
                    children: [
                      Image.asset(
                        'assets/image/psd_y.png',
                        width: 20,
                        height: 20,
                      ),
                      SizedBox(
                        width: 20,
                      ),
                      Expanded(child: TextField(
                        maxLines: 1,
                        cursorColor: Colors.white,
                        style: TextStyle(fontSize: 15, color: Colors.white),
                        onChanged: (value) {
                          model.setPsd(value);
                        },
                        obscureText: model.eyes,
                        decoration: InputDecoration(
                          border: InputBorder.none,
                          hintText: 'Password',
                          hintStyle: TextStyle(
                              fontSize: 15,
                              fontWeight: FontWeight.bold,
                              fontFamily: 'my_medium',
                              color: Colors.grey),
                          suffixIcon: FlatButton(
                              onPressed: () {
                                model.setEyes();
                              },
                              child: Icon(Icons.remove_red_eye,color: MyColor.yellow,)),
                        ),
                      ))
                    ],
                  ),
                ),
                GestureDetector(
                  behavior: HitTestBehavior.opaque,
                  onTap: (){
                    model.login();
                  },
                  child: Container(
                    width: MediaQuery.of(context).size.width,
                    height: 50,
                    margin: EdgeInsets.only(top: 60),
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular((30)),
                        color: MyColor.qin
                    ),
                    child: Center(
                      child: Text(
                        'Confirm',
                        style: TextStyle(
                          color: Colors.white,
                          fontWeight: FontWeight.bold,
                          fontSize: 15,
                        ),
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        );
      },
    );
  }

}